#include <iostream>
#include <string>
using namespace std;

string s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

void n_to_x(int n, int x)
{
	if(n >= x)
		n_to_x(n / x, x);
	cout << s[n % x];
}

int main()
{
	int n, x;
	cin >> n >> x;
	n_to_x(n, x);
	return 0;
}
